<?php

namespace App\Models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;

/**
 * Class User
 * *
 * @property $user_id  唯一用户ID
 * @property $nickname  用户昵称
 * @property $sex  性别 0:未知 1:男 2:女
 * @property $avatar  用户头像
 * @property $phone  用户手机
 * @property $mini_openid  小程序openid
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
 *
 * @package  App\Models
 * @mixin \Illuminate\Database\Eloquent\Builder
 */
class User extends Authenticatable implements JWTSubject
{
    use SoftDeletes;
    public $incrementing = false;
    protected $table = 'users';

    protected $fillable = ['id', 'user_id', 'nickname', 'sex', 'avatar', 'phone', 'mini_openid'];

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    public function getJWTCustomClaims()
    {
        return [];
    }
}
